package com.example.back.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.back.bean.UserInfo;
import com.example.back.bean.user.User;
import com.example.back.dao.UserDao;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Api(tags = "获取用户信息接口")
@RestController
@RequestMapping("/user")
public class UserController {

    private static Logger logger= LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserDao userDao;

    @ApiOperation(value = "获取所有用户信息", notes = "已废弃",httpMethod = "GET")
    @RequestMapping("/getAll")
    public List<UserInfo> getAll(){
        return userDao.getAll();
    }

    @ApiOperation(value = "获取所有用户信息", notes = "获取所有用户信息",httpMethod = "GET")
    @RequestMapping("/getAllUserInfo")
    public List<User> getAllUserInfo(){
        return userDao.getAllUserInfo();
    }

    @ApiOperation(value = "获取单个用户信息", notes = "获取单个用户信息",httpMethod = "GET")
    @RequestMapping("/getOneUserInfo")
    public List<User> getOneUserInfo(Long userId){
        return userDao.getOneUserInfo(userId);
    }

    @RequestMapping("/getOne")
    public UserInfo getOne( Long userId){
        return userDao.getOne(userId);
    }

    @ApiOperation(value = "获取所有在线的用户信息", notes = "获取所有在线的用户信息",httpMethod = "GET")
    @RequestMapping("/isOnline")
    public List<User> getIsOnline(Integer isOnline){
        return userDao.getIsOnline(isOnline);
    }

    @ApiOperation(value = "获取该时间段内注册的用户信息",httpMethod = "GET")
    @RequestMapping("/regTime")
    public List<User> getRegTime(Date startTime, Date endTime){
        return userDao.getRegUser(startTime,endTime);
    }

//    @RequestMapping("/test/{info}")
//    public String test(@PathVariable String info,@RequestParam String str){
//        System.out.println(info+"===info");
//        System.out.println(str+"===str");
//        return info;
//    }
}
